package com.sita.cfmoto.persistence;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;
import de.greenrobot.dao.AbstractDaoMaster;
import de.greenrobot.dao.identityscope.IdentityScopeType;

import com.sita.cfmoto.persistence.UserDao;
import com.sita.cfmoto.persistence.FriendDao;
import com.sita.cfmoto.persistence.TracksDao;
import com.sita.cfmoto.persistence.RouteDao;
import com.sita.cfmoto.persistence.RouteDataDao;
import com.sita.cfmoto.persistence.BluetoothDataDao;
import com.sita.cfmoto.persistence.RtResourceEntityDao;
import com.sita.cfmoto.persistence.RtBlacklistEntityDao;
import com.sita.cfmoto.persistence.RtNoteEntityDao;
import com.sita.cfmoto.persistence.CcDriverEntityDao;
import com.sita.cfmoto.persistence.CcDriverTicketEntityDao;
import com.sita.cfmoto.persistence.CcPassengerTicketEntityDao;
import com.sita.cfmoto.persistence.GroupChatDetailEventDao;
import com.sita.cfmoto.persistence.VehicleInfoDao;
import com.sita.cfmoto.persistence.BindedVehicleDao;
import com.sita.cfmoto.persistence.DynamicDao;
import com.sita.cfmoto.persistence.TopicAuthorDao;
import com.sita.cfmoto.persistence.TopicDao;
import com.sita.cfmoto.persistence.ActiveDao;
import com.sita.cfmoto.persistence.CommentDao;

// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.
/** 
 * Master of DAO (schema version 7): knows all DAOs.
*/
public class DaoMaster extends AbstractDaoMaster {
    public static final int SCHEMA_VERSION = 7;

    /** Creates underlying database table using DAOs. */
    public static void createAllTables(SQLiteDatabase db, boolean ifNotExists) {
        UserDao.createTable(db, ifNotExists);
        FriendDao.createTable(db, ifNotExists);
        TracksDao.createTable(db, ifNotExists);
        RouteDao.createTable(db, ifNotExists);
        RouteDataDao.createTable(db, ifNotExists);
        BluetoothDataDao.createTable(db, ifNotExists);
        RtResourceEntityDao.createTable(db, ifNotExists);
        RtBlacklistEntityDao.createTable(db, ifNotExists);
        RtNoteEntityDao.createTable(db, ifNotExists);
        CcDriverEntityDao.createTable(db, ifNotExists);
        CcDriverTicketEntityDao.createTable(db, ifNotExists);
        CcPassengerTicketEntityDao.createTable(db, ifNotExists);
        GroupChatDetailEventDao.createTable(db, ifNotExists);
        VehicleInfoDao.createTable(db, ifNotExists);
        BindedVehicleDao.createTable(db, ifNotExists);
        DynamicDao.createTable(db, ifNotExists);
        TopicAuthorDao.createTable(db, ifNotExists);
        TopicDao.createTable(db, ifNotExists);
        ActiveDao.createTable(db, ifNotExists);
        CommentDao.createTable(db, ifNotExists);
    }
    
    /** Drops underlying database table using DAOs. */
    public static void dropAllTables(SQLiteDatabase db, boolean ifExists) {
        UserDao.dropTable(db, ifExists);
        FriendDao.dropTable(db, ifExists);
        TracksDao.dropTable(db, ifExists);
        RouteDao.dropTable(db, ifExists);
        RouteDataDao.dropTable(db, ifExists);
        BluetoothDataDao.dropTable(db, ifExists);
        RtResourceEntityDao.dropTable(db, ifExists);
        RtBlacklistEntityDao.dropTable(db, ifExists);
        RtNoteEntityDao.dropTable(db, ifExists);
        CcDriverEntityDao.dropTable(db, ifExists);
        CcDriverTicketEntityDao.dropTable(db, ifExists);
        CcPassengerTicketEntityDao.dropTable(db, ifExists);
        GroupChatDetailEventDao.dropTable(db, ifExists);
        VehicleInfoDao.dropTable(db, ifExists);
        BindedVehicleDao.dropTable(db, ifExists);
        DynamicDao.dropTable(db, ifExists);
        TopicAuthorDao.dropTable(db, ifExists);
        TopicDao.dropTable(db, ifExists);
        ActiveDao.dropTable(db, ifExists);
        CommentDao.dropTable(db, ifExists);
    }
    
    public static abstract class OpenHelper extends SQLiteOpenHelper {

        public OpenHelper(Context context, String name, CursorFactory factory) {
            super(context, name, factory, SCHEMA_VERSION);
        }

        @Override
        public void onCreate(SQLiteDatabase db) {
            Log.i("greenDAO", "Creating tables for schema version " + SCHEMA_VERSION);
            createAllTables(db, false);
        }
    }
    
    /** WARNING: Drops all table on Upgrade! Use only during development. */
    public static class DevOpenHelper extends OpenHelper {
        public DevOpenHelper(Context context, String name, CursorFactory factory) {
            super(context, name, factory);
        }

        @Override
        public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
            Log.i("greenDAO", "Upgrading schema from version " + oldVersion + " to " + newVersion + " by dropping all tables");
            dropAllTables(db, true);
            onCreate(db);
        }
    }

    public DaoMaster(SQLiteDatabase db) {
        super(db, SCHEMA_VERSION);
        registerDaoClass(UserDao.class);
        registerDaoClass(FriendDao.class);
        registerDaoClass(TracksDao.class);
        registerDaoClass(RouteDao.class);
        registerDaoClass(RouteDataDao.class);
        registerDaoClass(BluetoothDataDao.class);
        registerDaoClass(RtResourceEntityDao.class);
        registerDaoClass(RtBlacklistEntityDao.class);
        registerDaoClass(RtNoteEntityDao.class);
        registerDaoClass(CcDriverEntityDao.class);
        registerDaoClass(CcDriverTicketEntityDao.class);
        registerDaoClass(CcPassengerTicketEntityDao.class);
        registerDaoClass(GroupChatDetailEventDao.class);
        registerDaoClass(VehicleInfoDao.class);
        registerDaoClass(BindedVehicleDao.class);
        registerDaoClass(DynamicDao.class);
        registerDaoClass(TopicAuthorDao.class);
        registerDaoClass(TopicDao.class);
        registerDaoClass(ActiveDao.class);
        registerDaoClass(CommentDao.class);
    }
    
    public DaoSession newSession() {
        return new DaoSession(db, IdentityScopeType.Session, daoConfigMap);
    }
    
    public DaoSession newSession(IdentityScopeType type) {
        return new DaoSession(db, type, daoConfigMap);
    }
    
}
